var isInjured;
var temperature;
var pulse;
var sYS ;
var dIA;

var bloodPressure;
var sdiseaseAge;
var age;
var currSexflag;
var ageFlag;//年龄标记

//疾病列表
var ills = [];
//疾病id列表
var ids = [];
//病症列表
var symptoms = [];

var symptomsArr = '';//用于传值给结果页面，生成病历

var curSex;

var currCrosAndCons = 'pros';
var currpart;

$(function(){
	  initPic(currSexflag);
	  changeRole();
	 
});

function toload(flag,Cons){
	
	$(".point").remove();
	$("#myCanvas").attr('width',$("img.ck_img").width());
	$("#myCanvas").attr('height',$("img.ck_img").height()); 

 	$.ajax({
       url: basePath+"partInteraction/getAllCoordinate.spring",
       data: {
           sexflag : currSexflag,
           prosAndCons :currCrosAndCons
       },
       type: "POST",
       dataType: 'json',
       cache: false,
       success: function (ret) {
           if (ret!=null) {
        	   
        		if ($('#loadingToast').css('display') != 'none') {
        			return;
        		}
        		$('#loadingToast').show();
	            for(var i=0;i<ret.length;i++){
				 	drawPoint(ret[i].coordinate_X,ret[i].coordinate_Y,ret[i].parts);
	            }
            	getIllnessBySexAndAge();
           }
       }
 	});
}

function showTooltip(x,y,color,contents) {
	var my = document.getElementById("tooltip");
	    if (my != null){
        	my.parentNode.removeChild(my);
        }
	$('<div id="tooltip">' + contents + '<div>').css({
		position: 'absolute',
		display: 'none',
		top: y-30,
		left: x-35,
		border: '1px solid ' + color, 
		padding: '5px',
		'font-size': '10px',
		'border-radius': '5px',
		'background': '#fff',
		'font-family': 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
	    opacity: 0.9
	}).appendTo(".canvas_box").fadeIn(200);
	
	$('#tooltip').click(function(){
		
		var my = document.getElementById("tooltip");
		var part=$("#tooltip").text();
	    if (my != null){
        	my.parentNode.removeChild(my);
        }
		getIllnessByPart(contents);
	    currpart=part;//值为空，导致出错
	});
	
}

function showPoint(x,y,part) {
	$('<div id="point'+x*y*800+'" class="point"><div>').css({
		position: 'absolute',
		display: 'none',
		top: y-5,
		left: x-5,
		border: '1px solid ' + '#9bc0de',
		padding: '5px',
		'border-radius': '5px',
		'background': '#fff',
		'font-family': 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
	    opacity: 0.05
	}).appendTo(".canvas_box").fadeIn(200);
	
	$('#point'+x*y*800+'').on('mouseover',function(){
	    $('#point'+x*y*800+'').css("background-color","yellow");
	    showTooltip(x,y,"#5bc0de",part);
	});

}


/**
 * 填写相关信息
 */
function writeText(){
	var w_height = $(window).height();
	sYS = $("#sYS").val();
	dIA = $("#dIA").val();
	pulse = $("#pulse").val();
	temperature = $("#temperature").val();
	var birth=$("#birth").text();
	curSex=$("#sex").text();
	var nowDate=new Date();
 	var dates=Math.abs((new Date(Date.parse(nowDate.toLocaleDateString().replace(/-/g,   "/"))).getTime())-(new Date(Date.parse(birth.replace(/-/g,   "/"))).getTime()))/(1000*60*60*24);
 	age=Math.floor(dates/365);
	sdiseaseAge=age;
	forCycleFill(temperature,pulse,sYS,dIA);
  	$('.leftmenu').css('height',w_height);
   	$('.leftmenu .leftmenu_con ').stop().animate({ left: '-100%' }, 400);
   	setTimeout(function(){
       	$('.leftmenu,.bg_mark').fadeOut('fast');
    },200);
   
}
/**
 * 填写不详就退出弹窗
 * @returns
 */
function noWriteText(){
}

//一
function getIllnessBySexAndAge(){
		$.ajax({
         url: basePath+"illOper/getIllnessBySexAndAge.spring",
         data: {
             sex : curSex,
             age : ageFlag
         },
         type: "POST",
         dataType: 'json',
         cache: false,
         success: function (ret) {
             if(ret!=null){
             	ills = ret.ills;
             	ids = ret.ids;
             }
             $('#loadingToast').hide();
	         setTimeout(function() {
	        	pop("isage");
	         }, 800);
         }
     });
}

function forCycleFill(temperature,pulse,sYS,dIA){
	if(temperature){
		getIllnessByIdsAndSymptom("体温",temperature);
		symptoms.push("体温");
	}
	 if(pulse){
		getIllnessByIdsAndSymptom("脉搏",pulse);
		symptoms.push("脉搏");
	}
	if(sYS && dIA){
		getIllnessByIdsAndSymptom("舒张压",dIA);
		getIllnessByIdsAndSymptom("收缩压",sYS);
		symptoms.push("舒张压");
		symptoms.push("收缩压");
	}
}

//二,根据体温获取疾病id
function getIllnessByIdsAndSymptom(symptom,value){
	symptomsArr += "病症："+symptom+"，";
	symptomsArr += "数值："+value+"°C；";
	$.ajax({
         url: basePath+"illOper/getIllnessByIdsAndSymptom.spring",
         data: {
         	ids : ids.join(","),
            symptom : symptom,
            value : value
         },
         type: "POST",
         dataType: 'json',
         cache: false,
         success: function (ret) {
             if(ret!=null){
             	ills = ret.ills;
             	ids = ret.ids;
             }
         }
     });
}

//三
function getIllnessByPart(part){
	var $loadingToast = $('#loadingToast');
	if ($loadingToast.css('display') != 'none') {
		return;
	}
	$loadingToast.show();
 	if(ids.length==0){
 	 setTimeout(function() {
			$loadingToast.hide();
			alert("您查询的疾病不存在，请联系您主治医生，给您带来不便请谅解！");
		}, 800);
 	return;
 	}
	$.ajax({
         url: basePath+"illOper/getIllnessByPart.spring",
         data: {
         	ids :ids.join(","),
            part : part
         },
         type: "POST",
         dataType: 'json',
         cache: false,
         success: function (ret) {
             if(ret!=null){
             	ills = ret.ills;
             	ids = ret.ids;
             	if(ids.length<=0){
             		 setTimeout(function() {
             			$loadingToast.hide();
             			alert("您查询的疾病不存在，请联系您主治医生，给您带来不便请谅解！");
                 		var backUrl=basePath+"inquiry/toSelfTest.spring";
                       	window.location.href=backUrl;
             		}, 800);
             		
             	}else{
             		$('#loadingToast').hide();
             		getSymptomsByillList(part);
             		
             	}
             }
         }
     });
}

//四
function getSymptomsByillList(part){
	window.location.href="./jsp/inquiry.jsp?ids="+ids.join(",")+"&symptoms="+symptoms.join(",")+"&part="+part+"&symptomsArr="+symptomsArr;
/*   	var url=basePath+"illOper/getPartSymptomsByillList.spring?ids="+ids.join(",")+"&symptoms="+symptoms.join(",")+"&part="+part;
 	window.location = url;*/
}

//五
function getSymptoms(symptom){
	$.ajax({
         url: basePath+"illOper/getSymptoms.spring",
         data: {
         	ids : ids,
         	symptom : symptom
         },
         type: "POST",
         dataType: 'json',
         cache: false,
         success: function (ret) {
             if(ret!=null){
             	degrees = ret.degrees;
             	medicines = ret.medicines;
             	timess = ret.timess;
             	natures = ret.natures;
             }
         }
     });	
}

//六
function getIllByIdAndsymptoms(symptom,degree,nature,times,value){
	$.ajax({
         url: basePath+"illOper/getIllByIdAndsymptoms.spring",
         data: {
         	ids : ids,
         	symptom : symptom,
         	symptoms : symptoms,
         	degree : degree,
         	nature : nature,
         	times :　times,
         	value : value
         },
         type: "POST",
         dataType: 'json',
         cache: false,
         success: function (ret) {
             if(ret!=null){
             	symptoms = ret.syms;
             	ids = ret.ids;
             }
         }
     });
}

function checkill(symptom,ids){
	$("#checkwrap").show();
	$("#checkwrap").dialog({
         	title   : "问题",
        	'class' :  "mydialog",
        	onClose : function() { 
         		$(this).dialog("close");
          	}, 
          	buttons : [{
          		text : "提交",
          		'class' : "btn btn-primary",
             	click : function() {
                    $.ajax({
                     url: basePath+"illOper/getIllByparts.spring",
                     data: {
                         symptom: symptom,
                         ids : ids
                     },
                     type: "POST",
                     dataType: 'json',
                     cache: false,
                     success: function (ret) {
                         if(ret.resultCode==1){
                         	window.location = basePath+"jsp/illness/bodysimulation.jsp";
                         }
                     }
                 });
             	}
             },{
             text : "关闭",
             'class' : "btn btn-default",
             click : function() {
                	 $(this).dialog("close");
             	}
         }]
     });
}

//编辑点
function editPoint(x,y,partName){
		if(confirm("确定选择该部位吗?")){ 
			getIllByparts(partName,0);
			console.log(getIllByparts(partName,1));
			getData(partName);
			}
			else{ 
			}
}


//显示部位所有的相关疾病
function showill(ret,partName){
	$("#showillnamewrap").show();
	createNode("showill",ret.ills);
	$("#showillnamewrap").dialog({
       	title   : partName+"相关疾病:",
      	'class' :  "mydialog",
      	onClose : function() {
      		deleteNode("showill"); 
       		$(this).dialog("close");
        	}, 
        	buttons : [{
        		text : "下一步",
        		'class' : "btn btn-primary",
           	click : function() {
           		$(this).dialog("close");
                  getSymptomsByillList(ret.ids);
           	}
           },{
           text : "退出",
           'class' : "btn btn-default",
           click : function() {
           		deleteNode("showill");	
              	$(this).dialog("close");
           	}
       }]
   });
}

//添加所有子节点
function createNode(name,args){
	var div = document.getElementById(name);
	for(var i=0;i<args.length;i++){
		var textNode = document.createTextNode(args[i]+" ");
		div.appendChild(textNode);
	}
}

//删除所有子节点
function deleteNode(name){
	var div = document.getElementById(name);
  while(div.hasChildNodes()) //当div下还存在子节点时 循环继续
  {
      div.removeChild(div.firstChild);
  }
}


//显示所有的病症，可以单选
function showSymptoms(symptoms,ids,usedSymptoms){
	$("#showsymptomwrap").show();
	var mySelect = document.getElementById("symptoms");
	for(var i=0;i<symptoms.length;i++){
		var opp = new Option(symptoms[i],symptoms[i]);
		mySelect.add(opp);
	}
	$("#showsymptomwrap").dialog({
       	title   : "请选择一项相关病症:",
      	'class' :  "mydialog",
      	onClose : function() {
      		deleteNode("symptoms"); 
       		$(this).dialog("close");
        	}, 
        	buttons : [{
        		text : "下一步",
        		'class' : "btn btn-primary",
           	click : function() {
           		usedSymptoms.push($("#symptoms").val());
                  $.ajax({
                   url: basePath+"illOper/getIllByIdAndsymptoms.spring",
                   data: {
                       symptom: $("#symptoms").val(),
                       symptoms : usedSymptoms.join(","),
                       ids : ids
                   },
                   type: "POST",
                   dataType: 'json',
                   cache: false,
                   success: function (ret) {
                       if(ret!=null){
                       	if(ret.syms!=null){
                       		illQuestion(ret.syms,ret.ids);
                       	}
                       }
                   }
               });
           	}
           },{
           text : "关闭",
           'class' : "btn btn-default",
           click : function() {
           		deleteNode("symptoms"); 
              	$(this).dialog("close");
           	}
       }]
   });
}

//疾病问题操作中
function illQuestion(syms,ids,partName){
	 var xingbie;
	 if(currSexflag=="male"){
		 xingbie=0;
	 }else{
		 xingbie=1;
	 }
	var url=basePath+"inquiry/toIndex.spring?syms="+syms+"&ids="+ids+"&temperature="+temperature
			+"&sYS="+sYS+"&dIA="+dIA+"&pulse="+pulse+"&age="+sdiseaseAge+"&isInjured="+isInjured+"&type="+0
			+"&sex="+xingbie+"&parts="+partName;
	 window.location = url;
}

//删除数组的第一个元素
function delectFirstElement(arr){
	var reArr = [];
	for(var i=0;i<arr.length-1;i++){
		reArr.push(arr[i+1]);
	}
	return reArr;
}


function getData(partName,isInjured){
	 $('ul.inquiry').html("");
	 var xingbie;
	 if(currSexflag=="male"){
		 xingbie=0;
	 }else{
		 xingbie=1;
	 }
	$.ajax({
        url: basePath+"/illOper/getIllnessInParts.spring",
        data: {
            parts: partName,
            sex:xingbie,
            isInjured:isInjured,
            age : sdiseaseAge,
            temperature:temperature,
            pulse:pulse,
            type:0,
            sYS:sYS,
            dIA:dIA
        },
        type: "GET",
        dataType: 'json',
        cache: false,
        success: function (ret) {
            if(ret!=null){
            	if(ret.ids.length>0){
            		$.ajax({
            	         url: basePath+"illOper/getSymptomsByillList.spring",
            	         data: {
            	             ids: ret.ids.join(",")
            	         },
            	         type: "POST",
            	         dataType: 'json',
            	         cache: false,
            	         success: function (ret) {
            	        	 var toInquiryUrl="./inquiry/toIndex.spring?symptoms="+ret.symptoms+"&ids="+ret.ids+"&partName="+partName
            	        			 +"&temperature="+temperature+"&pulse="+pulse+"&sYS="+sYS+"&dIA="+dIA;
            	        	 window.location=toInquiryUrl;
            	         },
            	         error:function(){
            	        	 html="";
            	        	 html+="<li style=\"text-algin:center\">"+"<span>暂无数据</span> </li>";
            	        	 $("#inquiry").append(html);
            	         }
            	     });
            	}else{
            		html="";
               	 html+="<li style=\"text-algin:center\">"+"<span>暂无数据</span> </li>";
   	        	 $("#inquiry").append(html);
               }
            }else{
            		html="";
            	 html+="<li style=\"text-algin:center\">"+"<span>暂无数据</span> </li>";
	        	 $("#inquiry").append(html);
            }
        }
    });
    var w_height = $(window).height();
    $('.menu').css('height',w_height);
}

/**
 * 性别和年龄图片转换
 */
function  selectSex(sex){
	if(sex=="male"){
		var sexflag1='male';
		currSexflag='male';
		currCrosAndCons='pros';
		$("#maleck_img").show();
		$("#maleck_img1").hide();
		$("#femaleck_img").hide();
		$("#femaleck_img1").hide();
		$("#girlck_img").hide();
		$("#girlck_img1").hide();
		$("#boyck_img").hide();
		$("#boyck_img1").hide();
		$("#ertong").hide();
		$("#shaonian").hide();
		$("#zhongnian").show();
		$("#laonian").show();
		$("#qingnian").show();
	}
	if(sex=="female"){
		var sexflag1='female';
		currSexflag='female';
		currCrosAndCons='pros';
		$("#femaleck_img").show();
		$("#maleck_img").hide();
		$("#maleck_img1").hide();
		$("#femaleck_img1").hide();
		$("#girlck_img").hide();
		$("#girlck_img1").hide();
		$("#boyck_img").hide();
		$("#boyck_img1").hide();
		$("#ertong").hide();
		$("#shaonian").hide();
		$("#zhongnian").show();
		$("#laonian").show();
		$("#qingnian").show();
	}
	if(sex=="boy"){
		var sexflag1='boy';
		currSexflag='boy';
		currCrosAndCons='pros';
		$("#boyck_img").show();
		$("#maleck_img").hide();
		$("#maleck_img1").hide();
		$("#femaleck_img").hide();
		$("#femaleck_img1").hide();
		$("#girlck_img").hide();
		$("#girlck_img1").hide();
		$("#boyck_img1").hide();
		$("#zhongnian").hide();
		$("#laonian").hide();
		$("#qingnian").hide();
		$("#ertong").show();
		$("#shaonian").show();
	}
	if(sex=="girl"){
		var sexflag1='girl';
		currSexflag='girl';
		currCrosAndCons='pros';
		$("#girlck_img").show();
		$("#maleck_img").hide();
		$("#maleck_img1").hide();
		$("#femaleck_img").hide();
		$("#femaleck_img1").hide();
		$("#girlck_img1").hide();
		$("#boyck_img").hide();
		$("#boyck_img1").hide();
		$("#zhongnian").hide();
		$("#laonian").hide();
		$("#qingnian").hide();
		$("#ertong").show();
		$("#shaonian").show();
	}
	toload(currSexflag,currCrosAndCons);
	$("#mzm").show();
}

function  initPic(sex){
	if(sex=="male"){
		var sexflag1='male';
		currSexflag='male';
		currCrosAndCons='pros';
		$("#maleck_img").show();
		$("#maleck_img1").hide();
		$("#femaleck_img").hide();
		$("#femaleck_img1").hide();
		$("#girlck_img").hide();
		$("#girlck_img1").hide();
		$("#boyck_img").hide();
		$("#boyck_img1").hide();
		$("#ertong").hide();
		$("#shaonian").hide();
		$("#zhongnian").show();
		$("#laonian").show();
		$("#qingnian").show();
	}
	if(sex=="female"){
		var sexflag1='female';
		currSexflag='female';
		currCrosAndCons='pros';
		$("#femaleck_img").show();
		$("#maleck_img").hide();
		$("#maleck_img1").hide();
		$("#femaleck_img1").hide();
		$("#girlck_img").hide();
		$("#girlck_img1").hide();
		$("#boyck_img").hide();
		$("#boyck_img1").hide();
		$("#ertong").hide();
		$("#shaonian").hide();
		$("#zhongnian").show();
		$("#laonian").show();
		$("#qingnian").show();
	}
	if(sex=="boy"){
		var sexflag1='boy';
		currSexflag='boy';
		currCrosAndCons='pros';
		$("#boyck_img").show();
		$("#maleck_img").hide();
		$("#maleck_img1").hide();
		$("#femaleck_img").hide();
		$("#femaleck_img1").hide();
		$("#girlck_img").hide();
		$("#girlck_img1").hide();
		$("#boyck_img1").hide();
		$("#zhongnian").hide();
		$("#laonian").hide();
		$("#qingnian").hide();
		$("#ertong").show();
		$("#shaonian").show();
	}
	if(sex=="girl"){
		var sexflag1='girl';
		currSexflag='girl';
		currCrosAndCons='pros';
		$("#girlck_img").show();
		$("#maleck_img").hide();
		$("#maleck_img1").hide();
		$("#femaleck_img").hide();
		$("#femaleck_img1").hide();
		$("#girlck_img1").hide();
		$("#boyck_img").hide();
		$("#boyck_img1").hide();
		$("#zhongnian").hide();
		$("#laonian").hide();
		$("#qingnian").hide();
		$("#ertong").show();
		$("#shaonian").show();
	}
}
/**
 * 转身
 */
function turn(){
	if(currSexflag=="male"){
		if(currCrosAndCons=="pros"){//换背面
			currCrosAndCons='cons';
			$("#maleck_img1").show();
			$("#femaleck_img").hide();
			$("#maleck_img").hide();
			$("#femaleck_img1").hide();
			$("#girlck_img").hide();
			$("#girlck_img1").hide();
			$("#boyck_img").hide();
			$("#boyck_img1").hide();
			
		}else if(currCrosAndCons=="cons"){
			currCrosAndCons='pros';
			$("#maleck_img").show();
			$("#femaleck_img").hide();
			$("#maleck_img1").hide();
			$("#femaleck_img1").hide();
			$("#girlck_img").hide();
			$("#girlck_img1").hide();
			$("#boyck_img").hide();
			$("#boyck_img1").hide();
		}
	
	}
	if(currSexflag=="female"){
		if(currCrosAndCons=="pros"){//换背面
			currCrosAndCons='cons';
			$("#femaleck_img1").show();
			$("#femaleck_img").hide();
			$("#maleck_img").hide();
			$("#maleck_img1").hide();
			$("#girlck_img").hide();
			$("#girlck_img1").hide();
			$("#boyck_img").hide();
			$("#boyck_img1").hide();
			
		}else if(currCrosAndCons=="cons"){
			currCrosAndCons='pros';
			$("#femaleck_img").show();
			$("#maleck_img").hide();
			$("#maleck_img1").hide();
			$("#femaleck_img1").hide();
			$("#girlck_img").hide();
			$("#girlck_img1").hide();
			$("#boyck_img").hide();
			$("#boyck_img1").hide();
			
		}
	}
	if(currSexflag=="boy"){
		if(currCrosAndCons=="pros"){//换背面
			currCrosAndCons='cons';
			$("#boyck_img1").show();
			$("#femaleck_img").hide();
			$("#maleck_img").hide();
			$("#maleck_img1").hide();
			$("#femaleck_img1").hide();
			$("#girlck_img").hide();
			$("#girlck_img1").hide();
			$("#boyck_img").hide();
			
		}else if(currCrosAndCons=="cons"){
			currCrosAndCons='pros';
			$("#femaleck_img").hide();
			$("#maleck_img").hide();
			$("#maleck_img1").hide();
			$("#femaleck_img1").hide();
			$("#girlck_img").hide();
			$("#girlck_img1").hide();
			$("#boyck_img").show();
			$("#boyck_img1").hide();
			
		}
	}
	if(currSexflag=="girl"){
		if(currCrosAndCons=="pros"){//换背面
			currCrosAndCons='cons';
			$("#girlck_img1").show();
			$("#femaleck_img").hide();
			$("#maleck_img").hide();
			$("#maleck_img1").hide();
			$("#femaleck_img1").hide();
			$("#girlck_img").hide();
			$("#boyck_img").hide();
			$("#boyck_img1").hide();
			
		}else if(currCrosAndCons=="cons"){
			currCrosAndCons='pros';
			$("#girlck_img").show();
			$("#femaleck_img").hide();
			$("#maleck_img").hide();
			$("#maleck_img1").hide();
			$("#femaleck_img1").hide();
			$("#girlck_img1").hide();
			$("#boyck_img").hide();
			$("#boyck_img1").hide();
			
		}
	}
	toload(currSexflag,currCrosAndCons);
}
/**
 * 弹出年龄窗口
 */
function pop(id){
    var w_height = $(window).height();
    $('.leftmenu').css('height',w_height);
    //   弹出边菜单
    $('.leftmenu,.bg_mark').css('display','block');
    $('.leftmenu .leftmenu_con ' ).stop().animate({ left: '0' }, 400);
    if(id=="isage"){
    	 $("#isage").show();
    	 $("#ishurt").hide();
    }else{
    	 $("#ishurt").show();
    	 $("#isage").hide();
    }
   
    $('.cancle').click(function(){
    	  $('.leftmenu').css('height',w_height);
        $('.leftmenu .leftmenu_con ').stop().animate({ left: '-100%' }, 400);
        setTimeout(function(){
            $('.leftmenu,.bg_mark').fadeOut('fast');
        },200);
    });
}
/**
 * 选择年龄
 */
function selectAge(){
	var w_height = $(window).height();
	var radio=$("input[name='radio1']:checked").val();
	sdiseaseAge=radio;
	  $('.leftmenu').css('height',w_height);
      $('.leftmenu .leftmenu_con ').stop().animate({ left: '-100%' }, 400);
      setTimeout(function(){
          $('.leftmenu,.bg_mark').fadeOut('fast');
      },200);
}

/**
 * 选择是否受伤
 */
function isHurt(){
	var w_height = $(window).height();
	var radio=$("input[name='radio2']:checked").val();
	isInjured=radio;
	  $('.hurtmenu').css('height',w_height);
      $('.hurtmenu .hurtmenu_con ').stop().animate({ left: '-100%' }, 400);
      setTimeout(function(){
          $('.leftmenu,.bg_mark').fadeOut('fast');
      },200);
      getData(currpart,isInjured);
}

function allParts(){
	var w_height = $(window).height();
	var radio=$("input[name='radio2']:checked").val();
	isInjured=radio;
	  $('.hurtmenu').css('height',w_height);
      $('.hurtmenu .hurtmenu_con ').stop().animate({ left: '-100%' }, 400);
      setTimeout(function(){
          $('.leftmenu,.bg_mark').fadeOut('fast');
      },200);
      getData("全身",isInjured);
}

    function startInquiry(){
    	url=basePath+"jsp/inquiry.jsp";
		window.location.href = url;
	}
   
    function pop1(){
        var w_height = $(window).height();
        $('.theleftmenu').css('height',w_height);
        $('.theleftmenu').css('display','block');
        //   弹出边菜单
        $('.theleftmenu .bg_mark').css('display','block');
        
        $('.theleftmenu .theleftmenu_con ' ).stop().animate({ left: '0' }, 400);
        $('.cancle').click(function(){
        	  $('.theleftmenu').css('height',w_height);
            $('.theleftmenu .leftmenu_con ').stop().animate({ left: '-100%' }, 400);
            setTimeout(function(){
                $('.theleftmenu,.bg_mark').fadeOut('fast');
            },200);
        });
    }
    //切换角色
    function changeRole(){
    	pop1();
    	$.ajax({
    	       url: basePath+"user/selRole.spring",
    	       type: "POST",
    	       dataType: 'json',
    	       cache: false,
    	       success: function (ret) {
    	       var roleHTML="";
    	        $("#role").html("");
    	           if (ret.content!=null) {
    	               for(var i=0;i<ret.content.length;i++){
    	               roleHTML+="<label class=\"weui_cell weui_check_label\" for=\"x"+(i+1)+"\">";
    	                roleHTML+="<div class=\"weui_cell_bd weui_cell_primary\">";
    	                 roleHTML+=" <p>"+ret.content[i].userName+"</p> </div>";
    				 	  roleHTML+="<div class=\"weui_cell_ft\">";
    				 	   roleHTML+="<input type=\"radio\" class=\"weui_check\" name=\"radio100\" id=\"x"+(i+1)+"\" value="+ret.content[i].id+","+ret.content[i].isMainRole+">";
    				 	    roleHTML+="<span class=\"weui_icon_checked\"></span>";
    				 	    roleHTML+="</div></label>";
    				 	}
    				 	 $("#role").html(roleHTML);
    	           }
    	           
    	       }
    	   });
    
    }
    
//提交角色
    function tijiao(){
    	
    	var w_height = $(window).height();
    	var val=$("input[name='radio100']:checked").val();
    	$.ajax({
           url: basePath+"user/currRole.spring",
           type: "POST",
           data:{currRole:val},
           dataType: 'json',
           cache: false,
           success: function (ret) {
               if (ret.resultCode==1) {
            	   $('.theleftmenu').css('height',w_height);
            	      $('.theleftmenu .theleftmenu_con ').stop().animate({ left: '-100%' }, 400);
            	      setTimeout(function(){
            	          $('.theleftmenu,.bg_mark').fadeOut('fast');
            	      },200);
            	      storage.setItem("curSex",ret.content.curSex);
            	      storage.setItem("curage",ret.content.age);
            	      
            	      sdiseaseAge=storage.getItem("curage");
            	      curSex=storage.getItem("curSex");
            	      console.log("sdiseaseAge=年龄是=="+sdiseaseAge);
            	      if(sdiseaseAge>=0 && sdiseaseAge<=30){
            	      	ageFlag = 1;
            	      	
            	      }else if(sdiseaseAge>=31 && sdiseaseAge<=1459){
            	      	ageFlag =2;
            	      }else if(sdiseaseAge>=1460 && sdiseaseAge<=3284){
            	      	ageFlag = 3;
            	      }else if(sdiseaseAge>=3285 && sdiseaseAge<=5474){
            	      	ageFlag = 4;
            	      }else if(sdiseaseAge>=5475 && sdiseaseAge<=13139){
            	      	ageFlag = 5;
            	      }else if(sdiseaseAge>=13140 && sdiseaseAge<=23724){
              	      	ageFlag = 6;
              	      } else{
              	      	ageFlag = 7;
              	      } 
            	      if(sdiseaseAge<=5474 && curSex==1){
            	    		currSexflag='girl';
            	    	}else if(sdiseaseAge<=5474 && curSex==0){
            	    		currSexflag='boy';
            	    	}else if(sdiseaseAge>5474 && curSex==1){
            	    		currSexflag='female';
            	    	}else {
            	    		currSexflag='male';
            	    	}
            	      selectSex(currSexflag);
            	      
              }
               
           }
       });
    	  
    }
    /**
     * 全身
     * @returns
     */
    function wholeBody(){
    	getIllnessByPart("全身");
    }
    
    function query(){
    	 var w_height = $(window).height();
         $('.partmenu').css('height',w_height);
         $('.partmenu').css('display','block');
         //   弹出边菜单
         $('.partmenu .bg_mark').css('display','block');
         
         $('.partmenu .partmenu_con ' ).stop().animate({ left: '0' }, 400);
         $('.cancle').click(function(){
         	  $('.partmenu').css('height',w_height);
             $('.partmenu .partmenu_con ').stop().animate({ left: '-100%' }, 400);
             setTimeout(function(){
                 $('.partmenu,.bg_mark').fadeOut('fast');
             },200);
         });
    }
    //查询部位
    function toSearch(){
    	var search=$("#search").val();
    	var html="";
    	$("#cont").html("");
    	$.ajax({
            url: basePath+"illOper/queryParts.spring",
            type: "POST",
            data:{part:search},
            dataType: 'json',
            cache: false,
            success: function (ret) {
            	 if(ret.list.length>0){
            		 for(var i=0;i<ret.list.length;i++){
            			 html+="<div class=\"weui_cell\" style=\"width: 80%\" onclick=\"clickPart('"+ret.list[i].parts+"');\">";
                    	 html+=" <div class=\"weui_cell_bd weui_cell_primary\">";
                    	 html+="<p>"+ret.list[i].parts+"</p>";
                    	 html+="</div></div>";
            		 }
            		 $("#cont").html(html);
            	 }
            	
               
            }
        });
    }
    //取消
    function cancle(){
    	 var w_height = $(window).height();
    	  $('.partmenu').css('height',w_height);
          $('.partmenu .partmenu_con ').stop().animate({ left: '-100%' }, 400);
          setTimeout(function(){
              $('.partmenu,.bg_mark').fadeOut('fast');
          },200);
    }
    function clickPart(part){
    	getIllnessByPart(part);
    }